/****************************************************************************
**                                                                         **
**                         PSSDK HNLBSession module                        **
**            Copyright (c) 1997 - 2006 microOLAP Technologies LTD,        **
**                       Khalturin A.P., Naumov D.A.                       **
**                               Header File                               **
**                                                                         **
****************************************************************************/

//---------------------------------------------------------------------------
#ifndef __HN_PSSDK_LBSESSION_H__
#define __HN_PSSDK_LBSESSION_H__ 
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Class CHNLBSession
//---------------------------------------------------------------------------
class CHNLBSession
{
private:
    HANDLE hLbSes;

public:
    //###########################################################################
    //    Create & Destroy
    //###########################################################################

    //---------------------------------------------------------------------------
    // Contructor
    CHNLBSession() { hLbSes = NULL; }

    //---------------------------------------------------------------------------
    // Destructor
    ~CHNLBSession() { }

public:
    //###########################################################################
    //    Additionals methods
    //###########################################################################
    BOOL     IsValid() { return (BOOL)(hLbSes != NULL); }
    HANDLE   Get_Handle() { return hLbSes; }
    HANDLE   Set_Handle(HANDLE hLbSes) 
    { 
        this->hLbSes = hLbSes;
        return this->hLbSes; 
    }
    operator HANDLE() { return hLbSes; }
    HANDLE   operator =(HANDLE hLbSes) 
    {
        this->hLbSes = hLbSes;
        return this->hLbSes; 
    }

public:
    //###########################################################################
    //    Methods of redirect
    //###########################################################################

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetCreateTime - Returns the creation time of TCP session, which localhost is participating in.
#ifdef _WIN64
    LONGLONG GetCreateTime() 
    { return LbSesGetCreateTime(hLbSes); }
#else
    DWORD GetCreateTime(DWORD *pHiValue) 
    { return LbSesGetCreateTime(hLbSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetCloseTime - Returns the closing time of TCP session, which localhost is participating in.
#ifdef _WIN64
    LONGLONG GetCloseTime() 
    { return LbSesGetCloseTime(hLbSes); }
#else
    DWORD GetCloseTime(DWORD *pHiValue) 
    { return LbSesGetCloseTime(hLbSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetProcessId - Returns PID of the process on the local system, which is participating in TCP session.
    DWORD GetProcessId() 
    { return LbSesGetProcessId(hLbSes); }

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetDirection - Returns the direction of TCP session creation as it is defined in the HNLBDirection enumeration.
    DWORD GetDirection() 
    { return LbSesGetDirection(hLbSes); }

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetHosts - Returns HNLBHosts object handle.
    HANDLE GetHosts() 
    { return LbSesGetHosts(hLbSes); }

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetLocalDataSize - Returns the size of data, sent by localhost to the remote host in bytes.
#ifdef _WIN64
    ULONGLONG GetLocalDataSize() 
    { return LbSesGetLocalDataSize(hLbSes); }
#else
    DWORD GetLocalDataSize(DWORD *pHiValue) 
    { return LbSesGetLocalDataSize(hLbSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetRemoteDataSize - Returns the size of data, received by the localhost from remote host in bytes.
#ifdef _WIN64
    ULONGLONG GetRemoteDataSize() 
    { return LbSesGetRemoteDataSize(hLbSes); }
#else
    DWORD GetRemoteDataSize(DWORD *pHiValue) 
    { return LbSesGetRemoteDataSize(hLbSes,pHiValue); }
#endif //_WIN64

    //---------------------------------------------------------------------------
    // v2.3 - LbSesGetUserData - Returns user-defined value, associated with TCP session.
    DWORD_PTR GetUserData() 
    { return LbSesGetUserData(hLbSes); }

    //---------------------------------------------------------------------------
    // v2.3 - LbSesSetUserData - Sets user-defined value, associated with TCP session.
    DWORD_PTR SetUserData(DWORD_PTR UserData) 
    { return LbSesSetUserData(hLbSes,UserData); }
};


//---------------------------------------------------------------------------
#endif // __HN_PSSDK_LBSESSION_H__ 
//---------------------------------------------------------------------------
